\section{network::receiver Class Reference}
\label{classnetwork_1_1receiver}\index{network::receiver@{network::receiver}}
This class receives strings from a socket, parses them and inserts messages into the message\_\-queue.  


{\tt \#include $<$receiver.h$>$}

Inheritance diagram for network::receiver::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3cm]{classnetwork_1_1receiver}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
\bf{receiver} (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ sock, boost::shared\_\-ptr$<$ \bf{network::message\_\-queue} $>$ queue, boost::shared\_\-ptr$<$ \bf{network::parser} $>$ pars)
\begin{CompactList}\small\item\em receiver is the constructor for this class. Don't call this contructor directly, use create instead. \item\end{CompactList}\item 
virtual \bf{$\sim$receiver} ()\label{classnetwork_1_1receiver_9e5a1ae9c9c6e10f8549170d6ee409d8}

\item 
virtual void \bf{run} ()
\begin{CompactList}\small\item\em run runs the receiver-thread. Don't call this method directly, use \doxyref{start\_\-thread()}{p.}{classnetwork_1_1worker__thread_79edd8c46081c1761ae00e8c00519554} instead. \item\end{CompactList}\item 
boost::shared\_\-ptr$<$ const \bf{network::i\_\-socket} $>$ \bf{get\_\-socket} () const 
\begin{CompactList}\small\item\em get\_\-socket returns the socket \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static boost::shared\_\-ptr$<$ \bf{network::receiver} $>$ \bf{create} (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ sock, boost::shared\_\-ptr$<$ \bf{network::message\_\-queue} $>$ queue, boost::shared\_\-ptr$<$ \bf{network::parser} $>$ pars)
\begin{CompactList}\small\item\em create creates a new receiver-object. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
This class receives strings from a socket, parses them and inserts messages into the message\_\-queue. 



Definition at line 49 of file receiver.h.

\subsection{Constructor \& Destructor Documentation}
\index{network::receiver@{network::receiver}!receiver@{receiver}}
\index{receiver@{receiver}!network::receiver@{network::receiver}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}network::receiver::receiver (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ {\em sock}, boost::shared\_\-ptr$<$ \bf{network::message\_\-queue} $>$ {\em queue}, boost::shared\_\-ptr$<$ \bf{network::parser} $>$ {\em pars})\hspace{0.3cm}{\tt  [inline]}}\label{classnetwork_1_1receiver_a1029901e966f416280eb889f62f227d}


receiver is the constructor for this class. Don't call this contructor directly, use create instead. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em sock}]is the socket from which messages should be received \item[{\em queue}]is the message\_\-queue into which messages should be inserted \item[{\em pars}]is the parses, with which strings should be parsed \end{description}
\end{Desc}


Definition at line 63 of file receiver.h.

\begin{Code}\begin{verbatim}66                 : _sock(sock), _queue(queue), _pars(pars) {}
\end{verbatim}\end{Code}




\subsection{Member Function Documentation}
\index{network::receiver@{network::receiver}!create@{create}}
\index{create@{create}!network::receiver@{network::receiver}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static boost::shared\_\-ptr$<$\bf{network::receiver}$>$ network::receiver::create (boost::shared\_\-ptr$<$ \bf{network::i\_\-socket} $>$ {\em sock}, boost::shared\_\-ptr$<$ \bf{network::message\_\-queue} $>$ {\em queue}, boost::shared\_\-ptr$<$ \bf{network::parser} $>$ {\em pars})\hspace{0.3cm}{\tt  [inline, static]}}\label{classnetwork_1_1receiver_eedf1749ac0f8eacd2c6dfedd5aa7f95}


create creates a new receiver-object. 

\begin{Desc}
\item[See also:]\doxyref{receiver}{p.}{classnetwork_1_1receiver} \end{Desc}
\begin{Desc}
\item[Returns:]a shared\_\-ptr to a receiver-object is returned. \end{Desc}


Definition at line 91 of file receiver.h.

\begin{Code}\begin{verbatim}95                 {
96                         boost::shared_ptr<network::receiver> rc(new
97                                 network::receiver(sock, queue, pars));
98                         rc->_this = rc;
99 
100                         return rc;
101                 }
\end{verbatim}\end{Code}


\index{network::receiver@{network::receiver}!get_socket@{get\_\-socket}}
\index{get_socket@{get\_\-socket}!network::receiver@{network::receiver}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}boost::shared\_\-ptr$<$const \bf{network::i\_\-socket}$>$ network::receiver::get\_\-socket () const\hspace{0.3cm}{\tt  [inline]}}\label{classnetwork_1_1receiver_2dfb4c6d20ada1f9d3588033210cab4f}


get\_\-socket returns the socket 

\begin{Desc}
\item[Returns:]a shared\_\-ptr to a socket is returned. \end{Desc}


Definition at line 80 of file receiver.h.

\begin{Code}\begin{verbatim}81                 {
82                         return _sock;
83                 }
\end{verbatim}\end{Code}


\index{network::receiver@{network::receiver}!run@{run}}
\index{run@{run}!network::receiver@{network::receiver}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void network::receiver::run ()\hspace{0.3cm}{\tt  [virtual]}}\label{classnetwork_1_1receiver_a473e1a94d7404664949c2485dfc854f}


run runs the receiver-thread. Don't call this method directly, use \doxyref{start\_\-thread()}{p.}{classnetwork_1_1worker__thread_79edd8c46081c1761ae00e8c00519554} instead. 

\begin{Desc}
\item[See also:]\doxyref{network::worker\_\-thread}{p.}{classnetwork_1_1worker__thread} \end{Desc}


Implements \bf{network::worker\_\-thread} \doxyref{p.}{classnetwork_1_1worker__thread_c2671b608908a5fb42d09317efb931dd}.

Definition at line 7 of file receiver.cpp.

\begin{Code}\begin{verbatim}8 {
9         while(1) {
10                 if(is_interrupted()) {
11                         return;
12                 }
13                 try {
14                         string tmp = _sock->recv();
15                         boost::shared_ptr<model::dom> ptr(_pars->parse(tmp));
16 
17                         boost::shared_ptr<network::message> msg(
18                                 new network::message);
19                         msg->sock = _sock;
20                         msg->node = ptr;
21                         msg->type = network::RECEIVE;
22 
23                         _queue->put(msg);
24                 } catch(const network::parse_exception &e) {
25                 } catch(const network::lost_connection_exception &e) {
26                         boost::shared_ptr<network::receiver> ptr(_this.lock());
27                         send_delete();
28                         _this.reset();
29                         return;
30                 } catch(const network::socket_exception &e) {
31                         boost::shared_ptr<network::receiver> ptr(_this.lock());
32                         send_delete();
33                         _this.reset();
34                         return;
35                 } catch(...) {
36                         cout << "strange exception" << endl;
37                         return;
38                 }
39         }
40 }
\end{verbatim}\end{Code}




The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
network/receiver.h\item 
network/receiver.cpp\end{CompactItemize}
